package cn.sym.basic.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置拦截器
 */
@Configuration  //标明此类为配置类
public class WebConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)   //添加自定义拦截器
                .addPathPatterns("/**")  //拦截所有资源
                //放行资源
                .excludePathPatterns("/login/**","/user/phoneRegister","/shop/settlement","/verifyCode/**","/fastDfs/**");
    }
}
